<template>
  <div>
    <button @click="getData1">点我获取分类数据</button> <br><br>
    <button @click="getData2">点我获取头条数据</button> <br><br>
    <button @click="getData3">点我获取百度数据</button> <br><br>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    name:'App',
    methods: {
      // 联系尚品汇的服务器
      getData1(){
        axios.get('http://sph-h5-api.atguigu.cn/api/product/getBaseCategoryList').then(
          (response)=>{
            console.log('成功',response.data)
          },
          (error)=>{
            console.log('失败',error)
          }
        )
      },
      // 联系头条的服务器
      getData2(){
        axios.get('/api1/hot-event/hot-board/?origin=toutiao_pc').then(
          (response)=>{
            console.log('成功',response.data)
          },
          (error)=>{
            console.log('失败',error)
          }
        )
      },
      // 联系百度的服务器
      getData3(){
        axios.get('/api2/widget?id=LocalNews&ajax=json').then(
          (response)=>{
            console.log('成功',response.data.data.LocalNews.data.rows.first)
          },
          (error)=>{
            console.log('失败',error)
          }
        )
      }
    },
  }
</script>
